﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NCP.Infrastructure.Common.Specification;
using NCP.Recruiting.Domain.Shared;

namespace NCP.Recruiting.Domain.Aggregates.Candidates
{
    public static class CandidateSpecifications
    {
        public static Specification<Candidate> GetCandidatesByCompanyId(Guid id)
        {
            return new DirectSpecification<Candidate>(t => t.CompanyId == id);
        }

        public static Specification<Candidate> GetCandidatesByStatus(int intStatus)
        {
            var status = (CandidateStatus)intStatus;
            switch(status)
            {
               
                case CandidateStatus.Optional:
                    {
                        return new DirectSpecification<Candidate>(t => t.Source == 2 && t.Deleted == false);
                    }
                case CandidateStatus.Replied:
                    {
                        return new DirectSpecification<Candidate>(t => t.IsReplied == true && t.Deleted == false);
                    }
                case CandidateStatus.Status:
                    {
                        return new DirectSpecification<Candidate>(t => t.Status != 0 && t.Deleted == false);
                    }
                case CandidateStatus.Taged:
                    {
                        return new DirectSpecification<Candidate>(t => t.TagId != null && t.Deleted == false);
                    }
                case CandidateStatus.Deleted:
                    {
                        return new DirectSpecification<Candidate>(t => t.Deleted == true);
                    }
                case CandidateStatus.All:
                default:
                    {
                        return new DirectSpecification<Candidate>(t => t.Deleted  == false);
                    }

            }
        }

        public static Specification<Candidate> GetCandidatesByKeyword(string keyword)
        {
            return new DirectSpecification<Candidate>(t => t.Jobposition.JobTitle.Contains(keyword));
        }

        public static Specification<Candidate> GetCandidatesByResumeId(Guid id)
        {
            return new DirectSpecification<Candidate>(t => t.ResumeId == id);
        }

        public static Specification<Candidate> GetCandidatesBySource(CandidateSourceType sourceType)
        {
            var source = (int)sourceType;
            return new DirectSpecification<Candidate>(t => t.Source == source);
        }
    }
}
